#include "drawingboard.h"
#include "ui_drawingboard.h"
#include <QPaintEvent >
#include <QResizeEvent>

DrawingBoard::DrawingBoard(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DrawingBoard)
{
    ui->setupUi(this);
    initUI();
}

DrawingBoard::~DrawingBoard()
{
    delete ui;
}

void DrawingBoard::updateBoard(const QPixmap &pixmap)
{
    m_pixmap = pixmap;
    update();
}

void DrawingBoard::paintEvent(QPaintEvent *)
{
    m_painter.begin(this);
    m_painter.drawPixmap(QPoint(0,0),m_pixmap);
    m_painter.end();
}

void DrawingBoard::resizeEvent(QResizeEvent *)
{
    m_pixmap.scaled(this->size());
    update();
}

void DrawingBoard::initUI()
{
    this->setAutoFillBackground(true);
    this->setPalette(QPalette(Qt::white));
    m_pixmap = QPixmap(size());
    m_pixmap.fill(Qt::white);

}
